<template>
  <div class="main">
    <div class="topbk">
      <div class="selectbox">
        <el-select placeholder="请选择项目" class="selectxm" v-model="selectproject" @change="handleChange" clearable size="small">
          <el-option v-for="(item, key) in dictOptions" :key="key" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </div>
      <div class="bjbox">
        <el-button size="mini" :class="{ active: isActive(index) }" :type="isPrimary(index) ? 'primary' : ''" v-for="(item, index) in classlist" :key="index" @click="checkclassid(item.classId, index)">{{ item.className }}</el-button>
      </div>
    </div>
    <div class="bottombk">
      <div class="leftbk">
        <a-tabs default-active-key="teachersign" v-model="activeKey" tab-position="left" :style="{ height: '100%' }" @change="changetab">
          <a-tab-pane key="teachersign">
            <template slot="tab">
              <div class="tabs_meun">
                <i class="el-icon-edit-outline"/>
                <label class="tabs_text">课前签到</label>
              </div>
            </template>
          </a-tab-pane>
          <a-tab-pane key="groupdiscussion">
            <template slot="tab">
              <div class="tabs_meun">
                <i class="el-icon-document-copy" />
                <label class="tabs_text">话题讨论</label>
              </div>
            </template>
          </a-tab-pane>
          <a-tab-pane key="randomName">
            <template slot="tab">
              <div class="tabs_meun">
                <i class="el-icon-thumb"/>
                <label class="tabs_text">随机点名1</label>
              </div>
            </template>
          </a-tab-pane>
          <a-tab-pane key="randomName2">
            <template slot="tab">
              <div class="tabs_meun">
                <i class="el-icon-mouse"/>
                <label class="tabs_text">随机点名2</label>
              </div>
            </template>
          </a-tab-pane>
          <a-tab-pane key="">
            <template slot="tab">
              <div class="tabs_meun">
                <i class="el-icon-edit" />
                <label class="tabs_text">随堂练习</label>
              </div>
            </template>
          </a-tab-pane>
          <a-tab-pane key="homework">
            <template slot="tab">
              <div class="tabs_meun">
                <i class="el-icon-tickets" />
                <label class="tabs_text">作业管理</label>
              </div>
            </template>
          </a-tab-pane>
        </a-tabs>
      </div>
      <div class="rightbk">
        <!--课前签到-->
        <teachersign v-if="activeKey == 'teachersign'" :classId="classId" :activeKey="activeKey"></teachersign>
        <!--话题讨论-->
        <groupdiscussion v-if="activeKey=='groupdiscussion'" :classId="classId"></groupdiscussion>
        <!--随机签名1-->
        <randomName ref="randomsign" v-if="activeKey == 'randomName'"></randomName>
        <!--随机签名2-->
        <randomName2 ref="randomsign2" v-if="activeKey == 'randomName2'"></randomName2>
        <!-- 作业 -->
        <homework ref="homework" v-if="activeKey == 'homework'"></homework>
      </div>
    </div>

  </div>

</template>

<script>


import {faceTeachgetProList, l_lecturergetClassList} from '@/api/apiz'
import teachersign from "./teachersign.vue";
import randomName from "./randomName.vue";
import randomName2 from "./randomName2.vue";
import groupdiscussion from './groupdiscussion.vue'
import homework from './homework.vue'

export default {
  name: '',
  components: {
    teachersign,
    randomName,
    randomName2,
    groupdiscussion,
    homework
  },
  data() {
    return {
      dictOptions: [],
      selectproject: '',//当前项目
      classlist: [],
      currentIndex: 0,
      activeKey: 'teachersign',
      classId: ''

    }
  },
  created() {
    this.getfaceTeachgetProList();

  },
  methods: {
    //查询项目
    async getfaceTeachgetProList() {
      let parms = {
        pageNo: 1,
        pageSize: 10
      }
      let res = await faceTeachgetProList(parms)
      if (res.code == 200 || res.code == '200') {
        this.dictOptions = res.result.map((item) => {
          return {
            id: item.id,
            name: item.name
          }
        }) || []
        //init 默认第一个
        if (this.dictOptions.length > 0) {
          this.selectproject = this.dictOptions[0].id
          this.getl_lecturergetClassList(this.selectproject, true)
        }
      }
    },
    //选择项目 切换班级
    handleChange(id) {
      this.getl_lecturergetClassList(id, true)
    },
    //查询班级
    async getl_lecturergetClassList(id, isinit) {
      let parms = {
        projectId: id
      }
      let res = await l_lecturergetClassList(parms);
      if (res.code == 200 || res.code == '200') {
        let list = res.result || []
        this.classlist = list.map((item) => {
          return {
            classId: item.classId,
            className: item.className
          }
        }) || []
        if (isinit) {
          if (this.classlist.length > 0) {
            this.checkclassid(this.classlist[0].classId, 0, true)
          }
        }

      }
    },
    //选择班级
    async checkclassid(classId, index, init) {
      this.currentIndex = index
      this.classId = classId
      this.activeKey = 'teachersign'

    },
    isPrimary(index) {
      return index === this.currentIndex;
    },
    isActive(index) {
      return index === this.currentIndex;
    },
    /* 切换tab */
    changetab(key) {
      this.activeKey = key
      //随机点名
      if (key == 'randomName') {
        this.$nextTick(() => {
          this.$refs.randomsign.getNamesData(this.classId)
        })
        return
      }
      //随机点名2
      if (key == 'randomName2') {
        this.$nextTick(() => {
          this.$refs.randomsign2.getNamesData(this.classId)
        })
        return
      }
    // 作业
      if (key == 'homework') {
        this.$nextTick(() => {
          this.$refs.homework.getHomeworkData(this.classId)
        })
        return
      }
    }
  },
  computed: {}
}
</script>
<style scoped lang='less'>
.main {
  height: calc(100vh - 75px);

  .topbk {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: #ffffff;
    border-radius: 10px;

    .selectbox {
      width: 240px;

      .selectxm {
        width: 280px;
      }
    }

    .bjbox {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: right;

      .ant-btn {
        margin-right: 10px;
      }
    }
  }

  .bottombk {
    height: calc(100% - 100px);
    display: flex;
    background: #ffffff;
    border-radius: 10px;

    .leftbk {
      width: 150px;
      height: 100%;
    }

    .tabs_meun {
      display: flex;
      align-items: center;
    }

    .tabs_text {
      font-size: 13px;
      font-weight: 500;
      margin-left: 10px;
    }

    .rightbk {
      height: 100%;
      flex: 1;

      .qdbk {
        padding-left: 20px;
        padding-right: 30px;

        .itembk {
          padding: 15px 16px;
          background: #fff;
          box-shadow: 0 0 6px 1px rgba(0, 0, 0, 0.16);
          border-radius: 3px;
          position: relative;
          margin-top: 15px;
          height: 140px;
          display: flex;

          .itembk1 {
            width: 20%;
            height: 100%;
            position: relative;
            border-right: 1px solid #e6e6e6;

            .title {
              color: #27313d;
              font-size: 17px;
              display: flex;
              align-items: center;

              &::before {
                content: "";
                width: 4px;
                height: 18px;
                background: #006eff;
                border-radius: 2px;
                margin-top: 3px;
                margin-right: 5px;
                margin-right: 11px;
                display: block;
              }
            }

            .qdrq {
              font-size: 14px;
              font-weight: 400;
              color: #27313d;
              line-height: 1;
              margin-top: 15px;
              padding-left: 14px;
            }

            .qdsj {
              font-size: 14px;
              font-weight: 400;
              color: #27313d;
              line-height: 1;
              margin-top: 15px;
              padding-left: 14px;
            }

          }

          .itembk2 {
            width: 40%;
            border-right: 1px solid #e6e6e6;
            display: flex;
            align-items: center;
            padding-left: 150px;
            justify-content: space-between;
            padding-right: 80px;

            .echarsbox {
              width: 120px;
              height: 120px;


            }

            .totalinfor {
              height: 100%;
              padding-top: 21px;
              width: 200px;
              font-size: 14px;
              font-weight: 400;
              color: #27313d;

              .infortop {
                display: flex;
                justify-content: space-between
              }

              .inforbm {
                margin-top: 20px;
                display: flex;
                justify-content: space-between
              }
            }
          }

          .itembk3 {
            width: 40%;
            height: 100%;
            display: flex;
            align-items: center;
            padding-left: 180px;

            .ewm {
              width: 80px;
              height: 80px;

              .img1 {
                width: 80px;
                height: 80px;
              }
            }

            .qdbtn {
              margin-left: 30px;
            }

            .xqa {
              margin-left: 30px;
            }
          }
        }
      }

      .qdsjb {
        padding-left: 20px;
        padding-right: 30px;

        .qdsjbsub {
          margin-top: 20px;
          background: #fff;
          box-shadow: 0 0 6px 1px rgba(0, 0, 0, 0.16);
          border-radius: 3px;
          padding: 15px 16px;

          .title {
            color: #27313d;
            font-size: 17px;
            display: flex;
            align-items: center;

            &::before {
              content: "";
              width: 4px;
              height: 18px;
              background: #006eff;
              border-radius: 2px;
              margin-top: 3px;
              margin-right: 5px;
              margin-right: 11px;
              display: block;
            }
          }
        }

      }
    }
  }
}

.iconfont.icon-rili {
  font-size: 24px;
  color: #1890FF;
  height: 28px;
}

.date {
  display: flex;
  align-items: center;

  .datefont {
    font-size: 18px;
    font-weight: 500;
    color: #5b687b;
    line-height: 1;
    margin-left: 5px;
    position: relative;
    top: 3px;
  }
}

.module {
  border-left: 2px solid #1890FF;
  padding: 14px 0 4px 16px;
  margin-left: 10px;

  .detail {
    height: 60px;
    border-radius: 4px;
    position: relative;
    margin-bottom: 5px;
    display: flex;

    .stateicon {
      position: absolute;
      border-radius: 4px 0 16px 0;
      padding: 3px 10px;
      font-size: 12px;
      line-height: 1;
      left: 0;
      top: 0;
    }

    .statewks {
      background-color: #858c96;
      color: #fff;
    }

    .stateywc {
      background: #51be34;
      color: #fff;
    }

    .statejxz {
      background: #ff7979;
      color: #fff;
    }

    .bk1 {
      width: 32%;
      height: 100%;
      display: flex;
      align-items: center;
      padding-left: 70px;
      display: flex;
      justify-content: space-between;
      font-size: 14px;
      font-weight: 400;
      color: #27313d;

      .feige {
        float: right;
        height: 30px;
      }

    }

    .bk2 {
      width: 45%;
      height: 100%;
      display: flex;
      position: relative;
      align-items: center;
      justify-content: center;

      span {
        margin-left: 15px;
      }

      .feige {
        float: right;
        position: absolute;
        right: 0px;
        top: 15px;
        height: 30px;
      }

    }

    .bk3 {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }


  }

  .ywc {
    border: 1px solid #1890Ff;
  }

  .jxz {
    border: 1px solid #ff7979;
  }

  .wks {
    border: 1px solid #bbbbbb;
  }


}

.infortop {
  display: flex;
  padding: 22px 0;

  .bk1 {
    width: 50%;
    position: relative;
    padding-top: 15px;

    .ant-divider-vertical {
      height: 50px;
      position: absolute;
      right: 0px;
      top: 0px;
    }

    ul {
      list-style: none;

      li {
        width: 250px;
        float: left;
        margin-bottom: 15px;
        font-size: 14px;
        font-weight: 400;
        color: rgba(0, 0, 0, .9);
        line-height: 1;
      }
    }
  }

  .bk2 {
    width: 50%;
    display: flex;
    padding-left: 76px;

    .echarsbox {
      width: 30%;
      height: 100%;
      position: relative;
      top: -33px;
    }

    .totalinfo {
      flex: 1;

      ul {
        list-style: none;

        li {
          width: 120px;
          float: left;
          margin-bottom: 10px;
        }
      }
    }
  }
}

/deep/ .ant-btn-primary:active,
.ant-btn-primary.active {
  height: 36px;

}

.tkbox {
  display: flex;
}

.tboxleft {
  width: 50%;
  height: 600px;
  overflow: scroll;
  display: flex;
  /* flex-direction: row; */
  flex-wrap: wrap;
  justify-content: left;
}

.tboxright {
  width: 50%;
  height: 600px;
}

.signpeop {
  width: 80px;
  height: 80px;
  border: 1px solid #e7e7e5;
  border-radius: 80px;
  float: left;
  margin-bottom: 15px;
}

#qrcode {
  width: 100%;
  height: 100%;
  margin-left: 20px;
}
</style>
